#ifndef __CEntityFactory_H__
#define __CEntityFactory_H__

#include "compfwk/compfwk.h"
#include "compfwk/ICompConfigStrategy.h"
#include "compfwk/IComponentServer.h"
#include "compfwk/IEntity.h"

namespace compfwk
{
    /**
     * \brief Singleton class to create entities of a especified type
     *
     * Each EntityFactory is loaded with several ComponentFactory to instanciate
     * each component the entity needs. Also it's loaded with a configuration
     * which has the responsibility of configuring the components.
     */
    class CEntityFactory
    {
    public:
        //! Constructs an empty EntityFactory
        CEntityFactory( const CString& ar_type, const CString& ar_desc );

        //! Add a component server to the configuration of the entity
        void AddComponentFactory( IComponentServer* ap_comp_server );

        //! Establish the configuration of the components
        void SetConfiguration( ICompConfigStrategy* ap_config );

        //! Create an entity with the given configuration
        IEntity* New( void ) const;

        //! Get the type of the entities this EntityFactory creates
        const CString& GetType( void ) const;

        //! Get the description of the type of the entities 
        //! this EntityFactory creates
        const CString& GetDescription( void ) const;

    private:
        //======================== DATA MEMBERS =============================
        //! Type of the entities this factory creates
        CString m_type;

        //! Description of the type of the entities this factory creates
        CString m_description;

        //! Vector that contains references to the component servers that create
        //! all the components needed for an entity of this factory
        CVector< IComponentServer* >::Ty m_v_comp_serv;

        //! Configuration for all the components of the entity
        ICompConfigStrategy* m_p_config;

        //======================== METHODS ==================================
        //! Copy constructor
        CEntityFactory( const CEntityFactory& ar_ent_fact );

        //! Assignment operator
        CEntityFactory& operator= ( const CEntityFactory& ar_ent_fact );
    };
}
#endif